package com.git.gitjob.user.controller;

import com.git.gitjob.user.mapper.UserMapper;
import com.git.gitjob.user.modle.domain.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/user")
public class UserController {



    @Resource
    private UserMapper userMapper;


    @PostMapping("add")
    public boolean add(@RequestBody  User user){
        int insert = userMapper.insert(user);
        if(insert == 1){
            return true;
        }
        return false;
    }

    @DeleteMapping("delete")
    public boolean deleteUser(@RequestBody int  id){
        int result = userMapper.deleteById(id);
        if(result == 1){
            return true;
        }
        return false;
    }

    @GetMapping("select")
    public boolean selectById(@RequestBody  int id){
        User user = userMapper.selectById(id);
        if(user != null){
            return true;
        }
        return false;
    }

}
